<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>检测对象类型</title>
</head>

<body>
    <p></p>
    <script>
        let test1 = Symbol('test1');
        console.log(test1); // Symbol(test)
        console.log(typeof (test1)); // symbol
        const PROP_NAME = Symbol('1')
        const PROP_AGE = Symbol()
        let obj = {
            [PROP_NAME]: "一斤代码"
        }
        obj[PROP_AGE] = 18

        obj[PROP_NAME] // '一斤代码'
        obj[PROP_AGE] // 18
        let s1 = Symbol()
        let s2 = Symbol('another symbol')
        let s3 = Symbol('another symbol')

        s1 === s2 // false
        s2 === s3 // false

        const PASSWORD = Symbol()
        class Login {
            constructor(username, password) {
                this.username = username
                this[PASSWORD] = password
            }

            checkPassword(pwd) {
                return this[PASSWORD] === pwd
            }
        }
        const login = new Login('admin', '123456')
        login.checkPassword('123456') // true

        login.PASSWORD // undefined
        login[PASSWORD] // undefined
        login["PASSWORD"] // undefined
    </script>
</body>

</html>